package top.oauth2.sms.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 定义短信验证码长度
 * @author xphu
 * @version 1.0
 * @date 2021/9/16 11:33
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum SmsLengthEnum {

    /** 4位短信验证码 */
    SMS_LENGTH_4(4),
    /** 6位短信验证码 */
    SMS_LENGTH_6(6),
    ;

    private int length;

    public static SmsLengthEnum getSmsLengthEnum(int length){
        for (SmsLengthEnum value : SmsLengthEnum.values()) {
            if (value.length == length) {
                return value;
            }
        }
        return null;
    }
}

